import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# 打开Chrome浏览器
driver = webdriver.Chrome()

time.sleep(2)
# 提交网址
driver.get('https://www.baidu.com')

# 定位到输入框
kw = driver.find_element(By.ID, 'kw')
# 输入搜索内容
kw.send_keys('武汉天气')

time.sleep(2)
# 定位搜索提交按钮
submit = driver.find_element(By.ID, 'su')
# 点击提交按钮
submit.click()

time.sleep(2)
# 刷新页面
driver.refresh()

time.sleep(3)
# 退出浏览器
driver.quit()
